package com.aspose.cells;

class zaip {
   private zoz a = null;
   private Worksheet b = null;
   private zpa c;
   private PageSetup d;
   private static final com.aspose.cells.b.c.a.za e = new com.aspose.cells.b.c.a.za(new String[]{"colorId", "guid", "filter", "filterUnique", "fitToPage", "hiddenColumns", "hiddenRows", "outlineSymbols", "printArea", "scale", "showAutoFilter", "showFormulas", "showGridLines", "showPageBreaks", "showRuler", "showRowCol", "showZeros", "view", "topLeftCell", "state", "pageLayout", "pageBreakPreview", "hidden", "veryHidden", "headerFooter", "pageMargins", "pageSetup", "extLst"});

   zaip(zoz var1, zpa var2) {
      this.a = var1;
      this.c = var2;
      this.b = var2.d;
      this.b.getCharts().a(new Chart(this.b));
      this.b.setType(2);
      this.d = this.b.getCharts().get(0).getPageSetup();
   }

   void a(zcfw var1) throws Exception {
      this.l(var1);
      if (!var1.n()) {
         var1.d();

         while(var1.r() != 4) {
            var1.j();
            if (var1.r() != 1) {
               var1.a();
            } else if ("sheetViews".equals(var1.p())) {
               this.j(var1);
            } else if ("sheetPr".equals(var1.p())) {
               this.h(var1);
            } else if ("pageMargins".equals(var1.p())) {
               this.c(var1, this.d);
            } else if ("pageSetup".equals(var1.p())) {
               this.b(var1, this.d);
            } else if ("headerFooter".equals(var1.p())) {
               this.a(var1, this.d);
            } else if ("legacyDrawing".equals(var1.p())) {
               this.i(var1);
            } else if ("drawing".equals(var1.p())) {
               this.g(var1);
            } else if ("sheetProtection".equals(var1.p())) {
               this.f(var1);
            } else if ("picture".equals(var1.p())) {
               this.e(var1);
            } else if ("customSheetViews".equals(var1.p())) {
               this.c(var1);
            } else if ("legacyDrawingHF".equals(var1.p())) {
               this.b(var1);
            } else {
               var1.a();
            }
         }

      }
   }

   private void b(zcfw var1) throws Exception {
      this.c.g = var1.a("id", (String)null);
      var1.a();
      if (this.c.g == null) {
         throw new CellsException(6, "Invalid LegacyDrawingHFRid element");
      }
   }

   private void c(zcfw var1) throws Exception {
      if (var1.n()) {
         var1.a();
      } else {
         var1.d();

         while(zass.a(var1)) {
            if ("customSheetView".equals(var1.p())) {
               this.d(var1);
            } else {
               var1.a();
            }
         }

      }
   }

   private void d(zcfw var1) throws Exception {
      znb var2 = new znb(this.b);
      this.b.D().a(var2);
      if (var1.m()) {
         while(var1.l()) {
            switch(e.a(var1.p())) {
            case 0:
               var2.f(zase.C(var1.s()));
               break;
            case 1:
               var2.n = new com.aspose.cells.b.a.zh(var1.s().substring(1, 1 + (var1.s().length() - 2)));
               break;
            case 2:
               var2.f(zase.ax(var1.s()));
               break;
            case 3:
               var2.g(zase.ax(var1.s()));
               break;
            case 4:
               var2.e().setPercentScale(!zase.ax(var1.s()));
               break;
            case 5:
               var2.b(zase.ax(var1.s()));
               break;
            case 6:
               var2.a(zase.ax(var1.s()));
               break;
            case 7:
               var2.r(zase.ax(var1.s()));
               break;
            case 8:
               var2.h(zase.ax(var1.s()));
               break;
            case 9:
               var2.c(zase.C(var1.s()));
               break;
            case 10:
               var2.e(zase.ax(var1.s()));
               break;
            case 11:
               var2.l(zase.ax(var1.s()));
               break;
            case 12:
               var2.m(zase.ax(var1.s()));
               break;
            case 13:
               var2.d(zase.ax(var1.s()));
               break;
            case 14:
               var2.s(zase.ax(var1.s()));
               break;
            case 15:
               var2.n(zase.ax(var1.s()));
               break;
            case 16:
               var2.q(zase.ax(var1.s()));
               break;
            case 17:
               switch(e.a(var1.s())) {
               case 20:
                  var2.d(2);
                  continue;
               case 21:
                  var2.d(1);
               default:
                  continue;
               }
            case 18:
               byte var3 = 0;
               byte var4 = 0;
               int[] var5 = new int[]{var3};
               int[] var6 = new int[]{var4};
               CellsHelper.a(var1.s(), var5, var6);
               int var7 = var5[0];
               int var8 = var6[0];
               var2.a(var7);
               var2.b(var8);
               break;
            case 19:
               switch(e.a(var1.s())) {
               case 22:
                  var2.e(1);
                  break;
               case 23:
                  var2.e(2);
               }
            }
         }
      }

      if (var1.n()) {
         var1.a();
      } else {
         var1.d();

         while(zass.a(var1)) {
            switch(e.a(var1.p())) {
            case 24:
               this.a(var1, var2.e());
               break;
            case 25:
               this.c(var1, this.b.getPageSetup());
               break;
            case 26:
               this.b(var1, var2.e());
               break;
            case 27:
               var2.c = var1.u();
               break;
            default:
               var1.a();
            }
         }

      }
   }

   private void e(zcfw var1) throws Exception {
      this.c.i = var1.a("id", (String)null);
      var1.a();
      if (this.c.i == null) {
         throw new CellsException(6, "Invalid Picture r:id element");
      }
   }

   private void a() {
      Protection var1 = this.b.getProtection();
      var1.setAllowEditingContent(true);
      var1.setAllowEditingObject(true);
   }

   private void f(zcfw var1) throws Exception {
      if (var1.m()) {
         this.a();
         Protection var2 = this.b.getProtection();

         while(var1.l()) {
            if ("password".equals(var1.p())) {
               var2.a(com.aspose.cells.b.a.zo.a(var1.s(), 515));
            } else if ("sheet".equals(var1.p())) {
               if ("0".equals(var1.s())) {
                  var2.setAllowEditingContent(true);
               } else {
                  var2.setAllowEditingContent(false);
               }
            } else if ("objects".equals(var1.p())) {
               if ("0".equals(var1.s())) {
                  var2.setAllowEditingObject(true);
               } else {
                  var2.setAllowEditingObject(false);
               }
            }
         }

         var1.k();
      }

      var1.a();
   }

   private void g(zcfw var1) throws Exception {
      this.c.h = var1.a("id", (String)null);
      var1.a();
      if (this.c.h == null) {
         throw new CellsException(6, "Invalid legacyDrawing element");
      }
   }

   private void h(zcfw var1) throws Exception {
      this.b.g.e = var1.a("published");
      String var2 = var1.a("codeName");
      if (var2 != null) {
         this.b.k = var2;
      }

      if (var1.n()) {
         var1.a();
      } else {
         var1.d();

         while(true) {
            while(var1.r() != 4) {
               var1.j();
               if ("sheetPr".equals(var1.p())) {
                  var1.d();

                  while(var1.r() != 4) {
                     var1.j();
                     if ("pageSetUpPr".equals(var1.p())) {
                        String var3 = var1.a("fitToPage");
                        if (var3 != null && "1".equals(var3)) {
                           this.d.setPercentScale(true);
                        }

                        var1.a();
                     } else {
                        var1.a();
                     }
                  }

                  var1.h();
               } else if ("tabColor".equals(var1.p())) {
                  this.b.j = zajp.g(var1);
               } else {
                  var1.a();
               }
            }

            var1.h();
            return;
         }
      }
   }

   private void i(zcfw var1) throws Exception {
      this.c.f = var1.a("id", (String)null);
      var1.a();
      if (this.c.f == null) {
         throw new CellsException(6, "Invalid legacyDrawing element");
      } else {
         String var2 = this.c.a(this.c.f);
         if (var2.charAt(0) == '/') {
            this.b.g.d = "xl" + var2.substring(3);
         } else {
            this.b.g.d = "xl" + var2.substring(2);
         }

      }
   }

   private void a(zcfw var1, PageSetup var2) throws Exception {
      if (var1.n()) {
         var1.a();
      } else {
         var1.d();

         while(true) {
            while(var1.r() != 4) {
               var1.j();
               if (var1.r() != 1) {
                  var1.a();
               } else {
                  String[] var3;
                  int var4;
                  if ("oddHeader".equals(var1.p())) {
                     var3 = a(var1.i());

                     for(var4 = 0; var4 < 3; ++var4) {
                        if (var3[var4] != null) {
                           var2.setHeader(var4, var3[var4]);
                        }
                     }
                  } else if ("oddFooter".equals(var1.p())) {
                     var3 = a(var1.i());

                     for(var4 = 0; var4 < 3; ++var4) {
                        if (var3[var4] != null) {
                           var2.setFooter(var4, var3[var4]);
                        }
                     }
                  } else {
                     var1.a();
                  }
               }
            }

            var1.h();
            return;
         }
      }
   }

   private static String[] a(String var0) {
      String[] var1 = new String[3];
      byte var2 = 1;
      int var3 = 0;

      for(int var4 = 0; var4 < var0.length(); ++var4) {
         if (var0.charAt(var4) == '&' && var4 + 1 < var0.length()) {
            byte var5;
            switch(var0.charAt(var4 + 1)) {
            case 'C':
            case 'c':
               var5 = 1;
               break;
            case 'L':
            case 'l':
               var5 = 0;
               break;
            case 'R':
            case 'r':
               var5 = 2;
               break;
            default:
               continue;
            }

            if (var4 - var3 > 0) {
               var1[var2] = var0.substring(var3, var3 + (var4 - var3));
            }

            var2 = var5;
            var3 = var4 + 2;
         }
      }

      if (var3 < var0.length()) {
         var1[var2] = var0.substring(var3);
      }

      return var1;
   }

   private void b(zcfw var1, PageSetup var2) throws Exception {
      if (!var1.m()) {
         var1.a();
      } else {
         this.a(var2);

         while(true) {
            while(var1.l()) {
               if ("blackAndWhite".equals(var1.p()) && "1".equals(var1.s())) {
                  var2.setBlackAndWhite(true);
               } else if ("cellComments".equals(var1.p())) {
                  var2.setPrintComments(zase.d(var1.s()));
               } else if ("draft".equals(var1.p()) && "1".equals(var1.s())) {
                  var2.setPrintDraft(true);
               } else if ("errors".equals(var1.p())) {
                  var2.setPrintErrors(zase.e(var1.s()));
               } else if ("firstPageNumber".equals(var1.p())) {
                  var2.setFirstPageNumber(zase.C(var1.s()));
               } else if ("fitToHeight".equals(var1.p())) {
                  var2.setFitToPagesTall(zase.C(var1.s()));
               } else if ("fitToWidth".equals(var1.p())) {
                  var2.setFitToPagesWide(zase.C(var1.s()));
               } else if ("horizontalDpi".equals(var1.p())) {
                  this.a(var2, var1.s());
               } else if ("verticalDpi".equals(var1.p())) {
                  this.a(var2, var1.s());
               } else if ("orientation".equals(var1.p())) {
                  var2.setOrientation(zase.c(var1.s()));
               } else if ("pageOrder".equals(var1.p())) {
                  var2.setOrder(zase.f(var1.s()));
               } else if ("paperSize".equals(var1.p())) {
                  var2.setPaperSize(zase.C(var1.s()));
               } else if ("scale".equals(var1.p())) {
                  int var3 = zase.C(var1.s());
                  if (var3 >= 10 && var3 <= 400) {
                     var2.setZoom(var3);
                  }
               } else if ("id".equals(var1.p())) {
                  this.c.j = var1.s();
               }
            }

            var1.k();
            var1.a();
            return;
         }
      }
   }

   private void a(PageSetup var1, String var2) {
      try {
         var1.setPrintQuality(zase.C(var2));
      } catch (Exception var4) {
         ;
      }

   }

   private void a(PageSetup var1) {
      var1.setPrintQuality(600);
   }

   private void c(zcfw var1, PageSetup var2) throws Exception {
      if (!var1.m()) {
         var1.a();
      } else {
         while(var1.l()) {
            if ("left".equals(var1.p())) {
               var2.setLeftMarginInch(zase.B(var1.s()));
            } else if ("right".equals(var1.p())) {
               var2.setRightMarginInch(zase.B(var1.s()));
            } else if ("top".equals(var1.p())) {
               var2.setTopMarginInch(zase.B(var1.s()));
            } else if ("bottom".equals(var1.p())) {
               var2.setBottomMarginInch(zase.B(var1.s()));
            } else if ("header".equals(var1.p())) {
               var2.setHeaderMarginInch(zase.B(var1.s()));
            } else if ("footer".equals(var1.p())) {
               var2.setFooterMarginInch(zase.B(var1.s()));
            }
         }

         var1.k();
         var1.a();
      }
   }

   private void j(zcfw var1) throws Exception {
      if (var1.n()) {
         var1.a();
      } else {
         var1.d();

         while(var1.r() != 4) {
            var1.j();
            if (var1.r() != 1) {
               var1.a();
            } else if ("sheetView".equals(var1.p())) {
               this.k(var1);
            } else {
               var1.a();
            }
         }

         var1.h();
      }
   }

   private void k(zcfw var1) throws Exception {
      boolean var2 = false;
      boolean var3 = false;
      this.b.getCharts().get(0).setSizeWithWindow(false);
      if (var1.m()) {
         while(true) {
            if (!var1.l()) {
               var1.k();
               break;
            }

            if ("showGridLines".equals(var1.p())) {
               this.b.setGridlinesVisible(zase.ax(var1.s()));
            } else if ("showRowColHeaders".equals(var1.p())) {
               this.b.setRowColumnHeadersVisible(zase.ax(var1.s()));
            } else if ("tabSelected".equals(var1.p())) {
               this.b.setSelected(zase.ax(var1.s()));
            } else if ("view".equals(var1.p())) {
               this.b.setPageBreakPreview("pageBreakPreview".equals(var1.s()));
            } else if ("zoomScale".equals(var1.p())) {
               this.b.setZoom(zase.C(var1.s()));
            } else if ("topLeftCell".equals(var1.p())) {
               String var4 = var1.s();
               byte var5 = 0;
               byte var6 = 0;
               int[] var7 = new int[]{var5};
               int[] var8 = new int[]{var6};
               CellsHelper.a(var4, var7, var8);
               int var9 = var7[0];
               int var10 = var8[0];
               this.b.setFirstVisibleRow(var9);
               this.b.setFirstVisibleColumn(var10);
            } else if ("zoomToFit".equals(var1.p())) {
               this.b.getCharts().get(0).setSizeWithWindow(zase.ax(var1.s()));
            }
         }
      }

      var1.a();
   }

   private void l(zcfw var1) throws Exception {
      var1.j();
      if (var1.r() != 1 || !"chartsheet".equals(var1.p())) {
         throw new CellsException(6, "chartsheet root element eror");
      }
   }
}
